package com.luo.controller;

import com.alibaba.fastjson.JSON;
import com.luo.model.ResultObj;
import com.luo.model.Summary;
import com.luo.service.SummaryService;
import net.sf.jsqlparser.schema.Server;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.ws.Service;
import java.io.IOException;

/**
 * 功能：
 * 作者：Luo。
 * 日期：2024/3/27 18:30
 */
@WebServlet("/queryOrderResult")
public class QueryOrderResultController extends HttpServlet {

	SummaryService summaryService = new SummaryService();

	@Override
	protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
		String id = req.getParameter("id");
		if (!id.isEmpty()){
			Summary summary = summaryService.querySummaryById(id);
			ResultObj result = new ResultObj();
			result.setCode("1");
			result.setMsg("查询成功");
			result.setResult(summary);
			String jsonString = JSON.toJSONString(result);

			resp.getWriter().write(jsonString);
			resp.getWriter().close();
		}
	}
}
